package com.qiwenshare.file.controller;

import com.qiwenshare.common.result.RestResult;
import com.qiwenshare.file.domain.RoleMenu;
import com.qiwenshare.file.domain.SysMenu;
import com.qiwenshare.file.api.SysMenuService;
import com.qiwenshare.file.vo.department.DepartmentTreeVo;
import com.qiwenshare.file.vo.menu.MenuVo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 菜单(SysMenu)表控制层
 *
 * @author MJ
 * @since 2023-09-20 11:11:44
 */
@RestController
@RequestMapping("sysMenu")
public class SysMenuController {
    /**
     * 服务对象
     */
    @Resource
    private SysMenuService sysMenuService;


    /**
     * 查询全量菜单
     *
     * @return
     */
    @Operation(summary = "查询全量菜单", description = "查询全量菜单", tags = {"菜单管理"})
    @RequestMapping(value = "/getAllMenuTree", method = RequestMethod.GET)
    @ResponseBody
    public RestResult<List<MenuVo>> getAllMenuTree() {
        return RestResult.success().data(sysMenuService.getMenuTree(null));
    }

    /**
     * 查询角色菜单
     *
     * @return
     */
    @Operation(summary = "查询角色菜单", description = "查询角色菜单", tags = {"菜单管理"})
    @RequestMapping(value = "/getMenuByRole", method = RequestMethod.GET)
    @ResponseBody
    public RestResult<List<RoleMenu>> getMenuByRole(@RequestParam(value = "roleId") Long roleId) {
        return RestResult.success().data(sysMenuService.getMenuByRole(roleId));
    }
}

